package com.weige.conver.handler;

import java.util.Map;

public class ConverContext {

    public static ConverHandler getInstance(String type){
        ConverHandler converHandler = null;
        Map<String,String> allClazz = ConverTypeEnum.getAllClazz();
        String clazz = allClazz.get(type);
        if (type != null && type.trim().length()>0) {
            try {
                try {
                    //调用无参构造器创建实例
                    converHandler = (ConverHandler) Class.forName(clazz).newInstance();
                } catch (InstantiationException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
        return converHandler;
    }
}
